import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import { h } from "vue";
import { MarkDown } from "@/components/Markdown";
import { Input } from "ant-design-vue";
import {getDictItems} from "@/api/common/api";
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '算法编码',
    align:"center",
    dataIndex: 'algorithmCode'
   },
   {
    title: '镜像最大版本',
    align:"center",
    dataIndex: 'imageMaxVersion'
   },
   {
    title: '镜像版本数量',
    align:"center",
    dataIndex: 'imageVersionNum'
   },
   {
    title: '厂家编码',
    align:"center",
    dataIndex: 'factoryCode'
   },
   {
    title: '镜像状态',
    align:"center",
    dataIndex: 'imageStatus_dictText'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remake'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "算法编码",
      field: 'algorithmCode',
      component: 'JSearchSelect',
      componentProps:{
        dict:"tbl_algorithm_info ,algorithm_code,algorithm_code"
      },
      //colProps: {span: 6},
 	},
     {
      label: "厂家编码",
      field: "factoryCode",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
	{
      label: "镜像状态",
      field: 'imageStatus',
      component: 'JSelectMultiple',
      componentProps:{
          dictCode:"valid_status"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '算法编码',
    field: 'algorithmCode',
    component: 'JSearchSelect',
    componentProps:{
      dict:"tbl_algorithm_info ,algorithm_code,algorithm_code",
    },
    dynamicRules: ({model,schema}) => {
        if(model['algorithmCode']){
          model['algorithmName'] = model['algorithmCode'];
          let factoryCode = model['algorithmCode'].split('-')[0];
          model['factoryCode'] = factoryCode;
          model['factoryName'] = factoryCode;
        }
          return [
                 { required: true, message: '请输入算法编码!'},
          ];
     },
  },
  {
    label: '算法名称',
    field: 'algorithmName',
    component: 'JSearchSelect',
    componentProps:{
      dict:"tbl_algorithm_info ,algorithm_name,algorithm_code",
    },
    dynamicRules: ({model,schema}) => {

      return [];
    },
    dynamicDisabled:true,
  },
  {
    label: '厂家编码',
    field: 'factoryCode',
    component: 'Input',
    dynamicDisabled:true,
  },
  {
    label: '厂家名称',
    field: 'factoryName',
    component: 'JSearchSelect',
    componentProps:{
      dict:"tbl_factory_info,factory_name,factory_code"
    },
    dynamicDisabled:true,
  },
  {
    label: '镜像状态',
    field: 'imageStatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"valid_status"
     },
  },
  {
    label: '备注',
    field: 'remake',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  algorithmCode: {title: '算法编码',order: 0,view: 'sel_search', type: 'string',dictCode: '',},
  imageMaxVersion: {title: '镜像最大版本',order: 1,view: 'text', type: 'string',},
  imageVersionNum: {title: '镜像版本数量',order: 2,view: 'text', type: 'string',},
  factoryCode: {title: '厂家编码',order: 3,view: 'text', type: 'string',},
  imageStatus: {title: '镜像状态',order: 4,view: 'list', type: 'string',dictCode: 'valid_status',},
  remake: {title: '备注',order: 5,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
